/*
 * KIMWONSORK@GMAIL.COM
 * COPYRIGHT CRAYONSOFT All rights reserved.
 * 2013오후 8:51:08
 * kws
 */

package com.crayon.account.item.adapter;


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;

import com.crayon.account.dao.DAOPhotos;

public class AdapterGridPhoto extends ArrayAdapter<DAOPhotos> {
	private LayoutInflater mInflater = null;
	public AdapterGridPhoto(Context context) {
		super(context,android.R.layout.simple_list_item_activated_1);
		// TODO Auto-generated constructor stub
		mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		//		convertView = convertView==null ? mInflater.inflate(android.R.layout.simple_list_item_activated_1, null, false):convertView;
		DAOPhotos item = getItem(position);
		//		convertView.setBackgroundResource(R.drawable.buttop_top_mid_dbl);
		ImageView imageView = 
				convertView!=null ? (ImageView)convertView:new ImageView(getContext());

		byte[] arrays = item.getArrays();
		if(arrays!=null){
			Bitmap bitmap = BitmapFactory.decodeByteArray(arrays, 0, arrays.length);
			imageView.setAdjustViewBounds(true); 
			imageView.setImageBitmap(bitmap);
		}


		return imageView;
	}

}
